<!--
// +----------------------------------------------------------------------
// | Created by PHPstorm: JRKAdmin框架 [ JRKAdmin ]
// +----------------------------------------------------------------------
// | Copyright (c) 2019~2022 [LuckyHHY] All rights reserved.
// +----------------------------------------------------------------------
// | SiteUrl: http://www.luckyhhy.cn
// +----------------------------------------------------------------------
// | Author: LuckyHhy <jackhhy520@qq.com>
// +----------------------------------------------------------------------
// | Date: 2020/3/2-14:46
// +----------------------------------------------------------------------
// | Description:
// +----------------------------------------------------------------------
*-->


{extend name='public/base' /}


{block name="content"}

<div class="layui-col-md12">

    <div class="layui-card">
        <div class="layui-card-body layui-row ">

            <blockquote class="layui-elem-quote layui-text">
                富文本编辑器使用开源项目：wangEditor<br>
                <a href="http://www.wangeditor.com" target="_blank" >wangEditor</a>
            </blockquote>

        </div>

    </div>

    <div class="layui-card">

        <div class="layui-card-body">

            <!--内容区-->
            <div class="layui-form">

                <div id="editors" >
                    <p>欢迎使用 <b>wangEditor</b> 富文本编辑器</p>
                </div>


                <pre class="layui-code" lay-title="JavaScript" lay-skin="notepad">//代码区域
 var editor = new wangEditor('#editors');
        editor.customConfig.uploadImgServer = "../upload.php"; //图片上传地址
        editor.customConfig.uploadFileName = 'image';
        editor.customConfig.pasteFilterStyle = false;
        editor.customConfig.uploadImgMaxLength = 5;
        editor.customConfig.uploadImgHooks = {
            // 上传超时
            timeout: function (xhr, editor) {
                layer.msg('上传超时！')
            },
            // 如果服务器端返回的不是 {errno:0, data: [...]} 这种格式，可使用该配置
            customInsert: function (insertImg, result, editor) {
                console.log(result);
                if (result.code == 1) {
                    var url = result.data.url;
                    url.forEach(function (e) {
                        insertImg(e);
                    })
                } else {
                    layer.msg(result.msg);
                }
            }
        };
        editor.customConfig.customAlert = function (info) {
            layer.msg(info);
        };
        editor.create();
      </pre>




            </div>


        </div>
    </div>

</div>


{/block}


{block name="js"} <!--js处理区-->



<script>

    layui.use(['element', 'form', 'jquery', 'lucky','wangEditor','code'], function () {
        var element = layui.element;
        var form = layui.form;
        var $ = layui.jquery;
        var lucky=layui.lucky;
        let wangEditor = layui.wangEditor;
        let code=layui.code;

        var editor = new wangEditor('#editors');
        editor.customConfig.uploadImgServer = "../upload.php"; //图片上传地址
        editor.customConfig.uploadFileName = 'image';
        editor.customConfig.pasteFilterStyle = false;
        editor.customConfig.uploadImgMaxLength = 5;
        editor.customConfig.uploadImgHooks = {
            // 上传超时
            timeout: function (xhr, editor) {
                layer.msg('上传超时！')
            },
            // 如果服务器端返回的不是 {errno:0, data: [...]} 这种格式，可使用该配置
            customInsert: function (insertImg, result, editor) {
                console.log(result);
                if (result.code == 1) {
                    var url = result.data.url;
                    url.forEach(function (e) {
                        insertImg(e);
                    })
                } else {
                    layer.msg(result.msg);
                }
            }
        };
        editor.customConfig.customAlert = function (info) {
            layer.msg(info);
        };
        editor.create();


    });

</script >


{/block}
